package com.yunshipei.core.net;

import org.json.JSONObject;

import java.util.Map;

import io.reactivex.Flowable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PartMap;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

public interface ServiceApi {

    @FormUrlEncoded
    @POST("/v2/companyInfo")
    Flowable<JSONObject> authCompany(@Field("cid") String cid);

    @FormUrlEncoded
    @POST("/v2/newLogin")
    Flowable<JSONObject> authDevice(@Field("companyId") String companyId, @Field("timestamp") long timeStamp, @Field("deviceInfo") String deviceInfo, @Field("sdk_sum") String sdkSum);

    @FormUrlEncoded
    @POST("v2/heartbeat")
    Flowable<JSONObject> heartBeat(@Field("companyId") String companyId, @Field("timestamp") long timeStamp, @Field("deviceToken") String token, @Field("uuid") String uuid, @Field("sdk_sum") String sdkSum);

    @POST("/api/runtime/download")
    @Streaming
    Flowable<Response<ResponseBody>> runtimeDownloadRequest(@Body RequestBody requestBody);

    @GET("/kernelInfo.json")
    @Streaming
    Flowable<JSONObject> kernelInfo();

    @GET("/v2/manifest")
    Flowable<JSONObject> allManifest(@Query("companyId") String companyId, @Query("uuid") String uuid);

    @GET
    @Streaming
    Flowable<Response<ResponseBody>> commonDownload(@Url String url);

    @GET
    Flowable<JSONObject> manifest(@Url String url);

    @FormUrlEncoded
    @POST("/v2/refresh/data")
    Flowable<JSONObject> dataJS(@Field("company") String companyId, @Field("uuid") String uuid, @Field("deviceInfo") String deviceInfo);

    @Multipart
    @POST("/debug/upload")
    Flowable<JSONObject> uploadLogFile(@PartMap Map<String, RequestBody> map);
}
